import java.util.Scanner;

/**
 * 12. 小平方
 * https://www.lanqiao.cn/problems/2378/learning/?page=1&first_category_id=1&second_category_id=3&tag_relation=intersection&tags=2021,%E7%9C%81%E8%B5%9B&sort=pass_rate&asc=0
 */
public class Main18 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int count = 0;
        double n = scan.nextInt();
        for(int i = 1;i < n;i++) {
            double x = (i * i) % n;
            if(x < (n / 2)) {
                count++;
            }
        }
        System.out.println(count);
        scan.close();
    }
}
